package com.hnchances.wjb.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnchances.wjb.Dto.GradesDto;
import com.hnchances.wjb.entity.Grades;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.sql.Wrapper;
import java.util.List;

@Mapper
public interface GradesMapper extends BaseMapper<Grades> {
    @Select("SELECT s.id, s.name, e.examName,co.courseName, g.grades,cl.className  "+"FROM student s, exam e, grades g , class cl, course co,teacher t  "+"WHERE s.name = '张三' AND t.classID = s.classID AND cl.id = g.classID AND co.id = g.courseID AND e.id = g.examID group by e.id")
    List<GradesDto> queryByUsername(@Param("username") String username,String className,String courseName,String examName,int teacherCourseId);


@Select("SELECT s.id, s.name, e.examName,co.courseName, g.grades,cl.className  "+"FROM student s, exam e, grades g , class cl, course co,teacher t  "+" ${ew.customSqlSegment} ")
Page<GradesDto> findBlog(IPage<GradesDto> page, @Param("ew") QueryWrapper wrapper);















   /* @Select("\"<script>\n" +
            "           SELECT s.id, s.name, e.examName,co.courseName, g.grades,cl.className FROM student s, exam e, grades g , class cl, course co,teacher t \n" +
            "            <where>\n" +
            "            <if test=\"gradesDto.name == true\">\n" +
            "             t1.is_put like ('%',#{gradesDto.name},'%')\n" +
            "            </if>\n" +
            "            <if test=\"gradesDto.examName == true\">\n" +
            "             t1.is_put like ('%',#{gradesDto.examName},'%')\n" +
            "            </if>\n" +
            "            <if test=\"gradesDto.courseName == true\">\n" +
            "             t1.is_put like ('%',#{gradesDto.courseName},'%')\n" +
            "            </if>\n" +
            "            <if test=\"gradesDto.className == true\">\n" +
            "             t1.is_put like ('%',#{gradesDto.className},'%')\n" +
            "            </if>\n" +
            "  </where>\n" +
            "AND t.classID = s.classID AND cl.id = g.classID AND co.id = g.courseID AND e.id = g.examID\n"+
            "    ORDER BY e.id\n" +
            "            </script>\"")
    IPage<GradesDto> selectAdLogisticsList(@Param("page") Page<GradesDto> pages, @Param("gradesDto") GradesDto gradesDto, int page, int pageSize);
*/

/*"\"<script>\n" +
        "            SELECT t1.id,t1.qiye_id,t1.member_tag,t1.name,t1.logo,t1.images,t1.video,t1.contacts_mobile,t1.contacts_name,t1.address,t1.sort,t1.sort,t1.click_num,t1.is_put,t1.company_type,t1.is_attestation,t1.is_recommend,t1.introduce,t1.create_time,t2.laoa_product_type_id AS productId,t3.laoa_style_id AS styleId FROM laoa_ad_logistics t1 LEFT JOIN laoa_product_middle t2 ON t1.qiye_id = t2.company_key LEFT JOIN laoa_style_middle t3 ON t1.qiye_id = t3.company_key\n" +
        "            <where>\n" +
        "            t1.company_type = 1\n" +
        "            <if test=\"adLogisticsVo.isOk == true\">\n" +
        "            AND t1.is_put = 1\n" +
        "            </if>\n" +
        "            <if test=\"adLogisticsVo.name != null\">\n" +
        "            AND t1.name LIKE CONCAT('%',#{adLogisticsVo.name},'%')\n" +
        "    </if>\n" +
        "    <if test=\"adLogisticsVo.styleId != null\">\n" +
        "    AND t3.laoa_style_id = #{adLogisticsVo.styleId}\n" +
        "    </if>\n" +
        "    <if test=\"adLogisticsVo.productId != null\">\n" +
        "    AND t2.laoa_product_type_id = #{adLogisticsVo.productId}\n" +
        "    </if>\n" +
        "  </where>\n" +
        "    ORDER BY t1.sort\n" +
        "            </script>\"")*/


}
